new Vue({
    el: "#app",
    data(){
        return {

            LoginFormDTO:{
                phone:"",
                password:"",
               
            },
            code:""
        }
    },
    methods:{
        // 登录
        login(){
            let _this=this
            
           
                    axios({
                        method:"post",
                        url: "http://localhost:8088/users/login",
                        data: _this.LoginFormDTO
                      }).then(function(resp){
                        
                        if(!resp.data.flag){
                            _this.$message({
                                message: resp.data.message,
                                type: 'error'
                            });
                        }else{
                            _this.$message({
                                message: resp.data.message,
                                type: 'success'
                            });
                            localStorage.authorization=resp.data.data.token
                            localStorage.id=resp.data.data.id
                            
                            setTimeout(function(){
                                location.href="platform.html"
                            },1000)
                            
                        }
          
                      })
             

            
        },
        // 注册
        register(){
            let _this=this
            axios({
                method:"post",
                url: "http://localhost:5500/users/register",
                data: _this.LoginFormDTO
              }).then(function(resp){
                
                if(!resp.data.flag){
                    _this.$message({
                        message: resp.data.message,
                        type: 'error'
                    });
                }else{
                    _this.$message({
                        message: resp.data.message,
                        type: 'success'
                    });
                }
  
              })
        },
        // 清除
        clear(){
            this.LoginFormDTO={}
        }
    }
})